﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Signum.Windows" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <Style TargetType="{x:Type m:ToolBarButton}" BasedOn="{StaticResource {x:Type Button}}">
        <Setter Property="Padding" Value="4,2,4,2"/>
        <Setter Property="Background" Value="Orange"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type m:ToolBarButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Timeline1">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.5"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Timeline2">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border CornerRadius="4,4,4,4" BorderThickness="1,1,1,1" SnapsToDevicePixels="True" x:Name="border1">
                        <Border x:Name="border" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3">
                            <Grid>
                                <Border x:Name="back" Width="Auto" CornerRadius="2,2,2,2"  Opacity="0" Background="{TemplateBinding Background}"/>
                                <Border x:Name="glow" Width="Auto" CornerRadius="2,2,2,2" Opacity="0">
                                    <Border.Background>
                                        <RadialGradientBrush GradientOrigin="0.5,0.5">
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.727" ScaleY="2.267"/>
                                                    <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                                                    <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
                                                    <TranslateTransform X="-0.017" Y="0.469"/>
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Offset="0" Color="#A0FFFFFF"/>
                                            <GradientStop Color="#00FFFFFF" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Border x:Name="shine" Width="Auto" CornerRadius="2,2,0,0"  Opacity="0">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                            <GradientStop Color="#50FFFFFF" Offset="0.545"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="{TemplateBinding Padding}" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Image Stretch="None" Source="{TemplateBinding Image}" HorizontalAlignment="Left" Grid.Column="0" x:Name="image"/>
                                    <ContentPresenter VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Center" Margin="4,0,4,0" x:Name="contentPresenter"  />
                                </Grid>

                            </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="image" Value="0.5"/>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline2}"/>
                            </Trigger.ExitActions>
                            <Setter Property="Opacity" TargetName="shine" Value="1"/>
                            <Setter Property="BorderBrush" TargetName="border1" Value="#FFC8C8C8"/>
                            <Setter Property="BorderBrush" TargetName="border" Value="#FFFFFFFF"/>
                            <Setter Property="Background" TargetName="border" Value="#7FABABAB"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="BorderBrush" TargetName="border1" Value="#FF5B5B5B"/>
                            <Setter Property="Opacity" TargetName="shine" Value="0.8"/>
                            <Setter Property="Background" TargetName="shine">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                        <GradientStop Color="#4CFFFFFF" Offset="1"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>